package hrms.service;

import hrms.util.Result;
import hrms.util.ws.phone.PhoneClient;
import hrms.util.ws.weather.WeatherClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Aikes on 2018-01-05.
 */

@Service("wsService")
public class WsServiceImpl implements WsService
{

	@Autowired
	private WeatherClient tWeatherClient;

	public Result<List<String>> queryWeather(String cCityName)
	{
		Result<List<String>> tResult = new Result<List<String>>();
		List<String> tList = tWeatherClient.getWeather(cCityName);
		List<String> resultList = new ArrayList<String>();
		for (int i = 0; i < tList.size(); i++)
		{
			if (!tList.get(i).endsWith(".gif"))
			{
				resultList.add(tList.get(i));
			}
		}
		System.out.println(resultList);
		tResult.setData(resultList);
		return tResult;
	}

	public Result<String> queryPhone(String cPhoneNum)
	{
		Result<String> tResult = new Result<String>();
		tResult.setData(new PhoneClient().getPhoneLocation(cPhoneNum));
		return tResult;
	}
}
